﻿using GalaSoft.MvvmLight;
using NtpChat.Client.Model;

namespace NtpChat.Client.ViewModel
{

    public class MessageViewModel : ViewModelBase
    {
        /// <summary>
        /// Initializes a new instance of the MessageViewModel class.
        /// </summary>
        /// 

        private Message message; 

        public MessageViewModel(Message message)
        {
            this.message = message;
        }

        /// <summary>
        /// The <see cref="FromUser" /> property's name.
        /// </summary>
        public const string FromPropertyName = "FromUser";

        public User FromUser
        {
            get
            {
                return message.FromUser;
            }

            set
            {
                if (message.FromUser == value)
                {
                    return;
                }

                var oldValue = message.FromUser;
                message.FromUser = value;

                // Update bindings, no broadcast
                RaisePropertyChanged(FromPropertyName);

            }
        }


        /// <summary>
        /// The <see cref="ToUser" /> property's name.
        /// </summary>
        public const string ToUserPropertyName = "ToUser";

        public User ToUser
        {
            get
            {
                return message.ToUser;
            }

            set
            {
                if (message.ToUser == value)
                {
                    return;
                }

                var oldValue = message.ToUser;
                message.ToUser = value;

                // Update bindings, no broadcast
                RaisePropertyChanged(ToUserPropertyName);

            }
        }


        /// <summary>
        /// The <see cref="Content" /> property's name.
        /// </summary>
        public const string ContentPropertyName = "Content";

        public string Content
        {
            get
            {
                return message.Content;
            }

            set
            {
                if (message.Content == value)
                {
                    return;
                }

                var oldValue = message.Content;
                message.Content = value;

                // Update bindings, no broadcast
                RaisePropertyChanged(ContentPropertyName);

            }
        }

    }
}